home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
utility
/
blrmu13.zip
/
PRT.ASM
< prev
next >
Wrap
Assembly Source File
|
1992-01-09
|
7KB
|
261 lines
page ,132
title prt ( multiple text file printer ) as of 01/09/92 - 09:25 pm
;*------------------------------------------
;
; print multiple text file copies
;
; syntax : prt n xxx.xxx
;
; where n = 1 - 9 copies
; where xxx.xxx = text file name
;
;*------------------------------------------
.model small
.code
;*------------------------------------------
include iomac.lib
;*------------------------------------------
;
mfs equ 32000 ; max file size
;
;*---------------------------
; definition of cmd line
;*---------------------------
org 128
;
pl db 0 ; parm len
db 0 ; space
amt db 0 ; amt ( of copies )
db 0
fn db 70 dup (0) ; file name
;
;*------------------------
; start of pgm
;*------------------------
org 256
go:
jmp prt
;
;*-----------------------
; data declarations
;*-----------------------
fpm db 13,10,10,' * PRTing '
fpnc db 'x'
db ' copies of '
fnv db 50 dup (' ')
db 13,10,10,'$'
;
sm db 13,10,10,' * syntax : prt n xxx.xxx'
db 13,10,' * where n = 1 - 9, and xxx.xxx = text file name'
db 13,10,10,'$'
;
fh dw 0 ; file handle
scx dw 0 ; save cx
abr dw 0 ; actual bytes read
filenlo dw 0 ; file len lo
filenhi dw 0 ; file len hi
;
; error messages
;
npem db 13,10,10,' * ERROR - no parameters ! * $'
plem db 13,10,10,' * ERROR - invalid parameter length ( no file name ? ) * $'
ofem db 13,10,10,' * ERROR - while opening file ! * $'
rfem db 13,10,10,' * ERROR - while reading file ! * $'
ftlem db 13,10,10,' * ERROR - File Too Large ( max size = 32000 bytes ) ! * $'
;
;*--------------------
; start of code
;*--------------------
prt:
;
cmp pl,0 ; no parm
je em1 ; if so, err 1 exit
;
cmp pl,2 ; 1 digit + space ?
jng em2 ; if not, err 2 exit
;
; get file name and count for display
;
lea si,fn ; ptr to srs
lea di,fnv ; ptr to dest
mov cl,pl ; parm len
mov ch,0 ; clr hi byte
sub cx,3 ; adjust len
cld
rep movsb ; move it
mov al,amt ; get amt
mov fpnc,al ; to msg
jmp pod ; process one digit
;
em1:
lea dx,npem ; no parm err msg
jmp pmcex
em2:
lea dx,plem ; parm len err msg
jmp pmcex
em3:
lea dx,ofem ; open file err msg
jmp pmcex
em4:
lea dx,rfem ; read file err msg
jmp pmcex
emtl:
lea dx,ftlem ; file too large err msg
jmp pmcex
;
; process one digit
;
pod:
;
cld ; forward
lea si,amt ; ptr to amt
lodsb ; put it in al
and al,15 ; make ascii binary
mov ch,0 ; clear ch
mov cl,al ; mov al to cl
;
; validate amt between 1 - 9
;
cmp cl,1 ; amt = 1 ?
jl ma1 ; if LT, make amt 1
;
cmp cl,9 ; amt = 9 ?
jg ma1 ; if GT, make amt 1
;
jmp sc ; ok, carry on
;
; make amt 1
;
ma1:
mov cl,1 ; set copy amt to 1
;
; save cx
;
sc:
mov scx,cx ; save copy amt
;
oaif fn,0 ; open the text file
;
jnc mfh ; if carry not set, carry on
jmp em3 ; err exit 3
;
mfh:
;
mov fh,ax ; save file handle
;
; check if file size too large
;
mfpffs fh,0,0,2
;
cmp filenhi,0
ja emtl
cmp filenlo,mfs
ja emtl
;
caf fh ; close file
oaif fn,0 ; open it again
;
raf fh,fia,mfs ; read the text file
;
jnc pf ; if carry not set, carry on
jmp em4 ; err exit 4
;
pf:
mov abr,ax ; save actual byte read
;
lea dx,fpm ; ptr to msg
call dasts ; display a string to scrn
;
; number of copies loop
;
nocl:
;
call tof ; top of form
;
lea si,fia ; ptr to file input area
mov cx,abr ; set cnt to actual bytes read
cld ; forward
;
; prt out loop
;
pol:
;
lodsb ; get a byte
mov dl,al ; and send it
mov ah,5 ; to prtr
int 33
loop pol ; abr times
;
call cr ; CR
call lf ; LF
call lf ; LF
;
mov cx,scx ; get copies cnt
cmp cx,1 ; 1 ?
je pmcx ; if so, thru
dec cx ; cnt - 1
mov scx,cx ; save it again
jmp nocl ; do it again
;
; normal exit
;
pmcx:
call tof ; top of form
pmcxe:
caf fh ; close the file
mov al,0 ; set cond code to 0
mov ah,76 ; exit
int 33
;
; error exit
;
pmcex:
;
call dasts ; display passed string to scrn
;
lea dx,sm ; ptr to syntax msg
call dasts ; display it
;
jmp pmcxe ; and exit
;
; Top of Form
;
tof proc near
mov dl,12
mov ah,5
int 33
ret
tof endp
;
; Line Feed
;
lf proc near
mov dl,10
mov ah,5
int 33
ret
lf endp
;
; Carriage Return
;
cr proc near
mov dl,13
mov ah,5
int 33
ret
cr endp
;
; Display A String To Screen
;
dasts proc near
mov ah,9
int 33
ret
dasts endp
;
; file input area
;
fia db 0
;
end go